﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class AtlasEffectData : EffectOneSourceData
    {
        #region 属性
        private Rect _sourceRectangle;
        private Rect _paddingRectangele;

        public Rect PaddingRectangele { get => _paddingRectangele; set { _paddingRectangele = value; OnPropertyChanged(); SetIsChanges(); } }
        public Rect SourceRectangle
        {
            get => _sourceRectangle; set
            {
                _sourceRectangle = value; OnPropertyChanged(); SetIsChanges();
            }
        }



        #endregion

        public override ICanvasImage GetEffect(CanvasDevice device, bool compression)
        {
            var source = GetSourceEffect(device, compression);
            if (source == null)
            {
                return null;
            }

            AtlasEffect effect = new AtlasEffect()
            {
                PaddingRectangle = PaddingRectangele,
                SourceRectangle = SourceRectangle,
                Source= source,
            };

            return effect;
        }
    }
}
